using System;
using AntEater.ComponentModel.Validation;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace AntEater.ComponentModel.BuildElements
{
    /// <summary>
    /// Provides the Item build element.
    /// </summary>
    [Serializable]
    [BuildElement("Item",HasDynamicElementName=true)]
    [ChildBuildElementType(typeof(ItemMetadataBuildElement))]
    [Icon(typeof(ItemBuildElement), "AntEater.ComponentModel.Resources.Item.ico")]
    public class ItemBuildElement : GenericContainerBuildElementBase
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="T:ItemBuildElement"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public ItemBuildElement(BuildFileDefinition context)
            : base(context) {
        }

        private string _condition;

        /// <summary>
        /// Gets or sets the condition.
        /// </summary>
        /// <value>The condition.</value>
        [BuildElementProperty("Condition", false, BuildElementPropertyType.Condition)]
        [Description("Optional attribute.\nCondition to be evaluated.")]
        [Category("MsBuild")]
        public string Condition {
            get { return _condition; }
            set {
                if (_condition != value) {
                    _condition = value;
                    OnPropertyChanged("Condition");
                }
            }
        }

        private string _include;

        /// <summary>
        /// Gets or sets the include.
        /// </summary>
        /// <value>The include.</value>
        [BuildElementProperty("Include", true, BuildElementPropertyType.String)]
        [Description("Required attribute.\nThe file or wildcard to include in the item.")]
        [Category("MsBuild")]
        public string Include {
            get { return _include; }
            set {
                if (_include != value) {
                    _include = value;
                    OnPropertyChanged("Include");
                }
            }
        }

        private string _exclude;

        /// <summary>
        /// Gets or sets the exclude.
        /// </summary>
        /// <value>The exclude.</value>
        [BuildElementProperty("Exclude", false, BuildElementPropertyType.String)]
        [Description("Optional attribute.\nThe file or wildcard to exclude in the item.")]
        [Category("MsBuild")]
        public string Exclude {
            get { return _exclude; }
            set {
                if (_exclude != value) {
                    _exclude = value;
                    OnPropertyChanged("Exclude");
                }
            }
        }

        /// <summary>
        /// Determines whether this instance is valid.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// 	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
        /// </returns>
        public override bool IsValid {
            get { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Validates the specified recursive.
        /// </summary>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        public override ReadOnlyCollection<ValidationResult> Validate(bool recursive) {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone() {
            ItemBuildElement newElement = base.Clone() as ItemBuildElement;

            if (this._condition != null) {
                newElement._condition = this._condition.Clone() as string;
            }
            if (this._exclude != null) {
                newElement._exclude = this._exclude.Clone() as string;
            }
            if (this._include != null) {
                newElement._include = this._include.Clone() as string;
            }

            return newElement;
        }
    }
}
